<?php

	/**
	 * Elgg thewire view page
	 * 
	 * @package ElggTheWire
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Curverider <info@elgg.com>
	 * @copyright Curverider Ltd 2008-2009
	 * @link http://elgg.com/
	 * 
	 */	
?>
<div class="sidebarBox">
<div class="membersWrapper"><br />
    <div class="fragment">
    	<h3> Demandes envoyées</h3>
			<?php 
				$validations = get_entities_from_metadata('validate','valide','object','',$_SESSION['user']->getGUID());
				echo '<ul>';
				foreach($validations as $v){
						$owner=get_entity($v->getOwner());
						echo '<li><h5><a href="'.$v->getUrl().'">'.$v->title.'</a></h5>'.friendly_time($v->time_updated).'</li>';
				}
				echo '</ul>';
			?>
    </div>
			<?php
			if($_SESSION['user']->role !='student'){
				
			?>
    <div class="fragment">
    	<h3> A valider</h3>
			<?php
				$compare='Demande de Validation';
				$messages=get_entities_from_metadata("toId", $_SESSION['user']->getGUID(), "object", "messages", $_SESSION['user']->guid);
				echo '<ul>';
				if(is_array($messages)){
					foreach($messages as $m){
						$tmp= substr($m->title, 0, 21);
						if($tmp==$compare){
							$int=strpos($m->description,'<a');
							echo '<li><h5>'.substr($m->description,$int).'</h5>'.friendly_time($m->time_created).'</li>'; 
						}
					}
				echo '</ul>';
				}
			?>
    </div>
		<?php
			}
		?>
</div>
</div>